package com.itheima.d6_tcp3.ZengTCpTest;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

/**
 * @ClassName client
 * @Author 16799
 * @Date 2025/9/26 19:47
 * @Version 1.0
 * @Description TODO
 **/
public class client {
    public static void main(String[] args) throws Exception {
        Socket socket = new Socket("127.0.0.1",8877);

        OutputStream os = socket.getOutputStream();
        DataOutputStream dos = new DataOutputStream(os);

        Scanner sc = new Scanner(System.in);
        while (true){
            System.out.println("请输入： ");
            String msg = sc.nextLine();
            if (msg.equals("exit")){
                System.out.println("退出当前的客户端");
                dos.close();
                socket.close();
                break;
            }

            dos.writeUTF(msg);
            dos.flush();
        }
    }
}
